package com.brambila.clickable;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

import com.brambila.interfaces.IFloor;
import com.brambila.interfaces.ITerrainImages;
import com.brambila.releaseme.Game;
import com.brambila.releaseme.R;

public class ViewBars implements ITerrainImages {

	Bitmap bitmap;
	int w, h;

	private Flag flag;
	private RemoveBomb bombCollector;
	private Signal signal;

	public ViewBars(int width, int height) {
		bitmap = BitmapFactory.decodeResource(Game.getResourcesGame(), R.drawable.game_bottombar);
		w = width;
		h = height;

		flag = new Flag((int) (GAME_FLAG.getWidth() * 0.6f), (int) (h - GAME_FLAG.getHeight() - (GAME_FLAG.getHeight() * 0.3f)),GAME_FLAG);
		bombCollector = new RemoveBomb(w / 2 - (GAME_FLAG.getWidth() / 2), (int) (h - GAME_FLAG.getHeight() - (GAME_FLAG.getHeight() * 0.3f)), GAME_REMOVEBOMB);
		signal = new Signal((int)(w - GAME_SIGNAL.getWidth() - (GAME_FLAG.getWidth() * 0.6f)), (int)(h - GAME_FLAG.getHeight() - (GAME_FLAG.getHeight() * 0.3f)), GAME_SIGNAL);
	}

	public void draw(Canvas canvas) {
		canvas.drawBitmap(bitmap, Game.getGame().getScrollX(), h - bitmap.getHeight() + Game.getGame().getScrollY(), null);
		
		signal.draw(canvas, h);
		bombCollector.draw(canvas, h);
		flag.draw(canvas, h);
	}

	public void touchEvent(int x, int y, int action, IFloor[][] mapWithMatrix) {
		flag.touchEvent(x, y, action, mapWithMatrix);
		bombCollector.touchEvent(x, y, action, mapWithMatrix);
		signal.touchEvent(x, y, action, mapWithMatrix);
	}
}